//
//  MyScrollViewController.m
//  封装scrollview
//
//  Created by Xue Senhong on 15/5/21.
//  Copyright (c) 2015年 薛森鸿. All rights reserved.
//

#import "MyScrollViewController.h"

@interface MyScrollViewController ()

@property (nonatomic, retain)UIScrollView *myScrollView;
@property (nonatomic, retain)UITableView *myTableView;

@end

@implementation MyScrollViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.array = [NSMutableArray array];
    }
    return self;
}

- (void)dealloc
{
    [self.array release];
    [super dealloc];
    
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.myScrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    self.myScrollView.backgroundColor = [UIColor yellowColor];
    // 滚动范围
    self.myScrollView.contentSize = CGSizeMake(self.array.count * self.view.frame.size.width, 0);
    //整屏滚动
    self.myScrollView.pagingEnabled = YES;
    //关闭弹动效果
    self.myScrollView.bounces = NO;
//   self.scroll.delegate = self;
    for (int i = 0; i < self.array.count; i ++) {
        self.myTableView = [self.array objectAtIndex:i];
        self.myTableView.frame = CGRectMake(0 * (i + self.view.frame.size.width), 64, self.view.frame.size.width, self.view.frame.size.height);
        [self.myScrollView addSubview:self.myTableView];
    }
    
    [self.view addSubview:self.myScrollView];
    [self.myScrollView release];
  
}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
